package org.example.musicserver.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.example.musicserver.common.Result;
import org.example.musicserver.service.BannerService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Tag(name = "轮播图相关接口")
public class BannerController {
    @Resource
    private BannerService bannerService;

    @GetMapping("/banner")
    @Operation(summary = "获取轮播图列表")
    public Result getAllBanner(){
        return Result.success("获取轮播图成功",bannerService.getAllBanner());
    }

    @PostMapping("/banner/add")
    @Operation(summary = "添加轮播图")
    public Result add(@RequestParam("file") MultipartFile file){
        return bannerService.addBanner(file);
    }

    @PostMapping("/banner/update")
    @Operation(summary = "修改轮播图")
    public Result update(@RequestParam Integer id,@RequestParam("file") MultipartFile file){
        return bannerService.updateBanner(id,file);
    }

    @PostMapping("/banner/delete")
    @Operation(summary = "删除轮播图")
    public Result delete(@RequestParam Integer id){
        return bannerService.deleteBanner(id);
    }



}
